package com.ziyucoding.springboot.labs.lab3.rocketmqdemo.consumer;

import com.ziyucoding.springboot.labs.lab3.rocketmqdemo.message.Demo1Message;
import com.ziyucoding.springboot.labs.lab3.rocketmqdemo.message.Demo2Message;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

/**
 * 示例2的消费者（用于批量发送消息）
 *
 * @author ziyucoding
 * @date 2022-10-20
 **/
@Component
@RocketMQMessageListener(topic = Demo2Message.TOPIC, consumerGroup = "demo2-consumer-group-" + Demo2Message.TOPIC
)
public class Demo2Consumer implements RocketMQListener<Demo2Message> {

    private Logger logger = LoggerFactory.getLogger(Demo2Consumer.class);

    @Override
    public void onMessage(Demo2Message message) {
        // 逐条消费信息
        logger.info("[onMessage][线程编号：{} 消息内容：{}]", Thread.currentThread().getId(), message);
    }
}
